<?php
# Alergias
echo "<table id=\"tablaAlergias\" cellspacing=\"0\" cellpadding=\"0\" class=\"formTable\">\n";

echo "<tr><td>\n";
echo "<table cellspacing=\"0\" cellpadding=\"0\" class=\"tokensTable\">\n";
echo "<tr>\n";
echo "<td class=\"blankToken\">&nbsp;</td>\n";
echo "<td class=\"activeToken2\"><nobr>Alergias</nobr></td>\n";
echo "<td class=\"blankToken\">&nbsp;</td>\n";
echo "<td class=\"token2\" onclick=\"mostrarTabla1('Antecmedic');\"><nobr>Antecedentes personales</nobr></td>\n";
echo "<td class=\"token2\" onclick=\"mostrarTabla1('Antecquirur');\"><nobr>Antecedentes quir&uacute;rgicos</nobr></td>\n";
echo "<td class=\"token2\" onclick=\"mostrarTabla1('Tratamhabit');\"><nobr>Tratamiento habitual</nobr></td>\n";
echo "<td class=\"lastToken\">&nbsp;</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</td></tr>\n";

echo "<tr valign=\"top\"><td class=\"tokenContent2\">\n";
echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n";
echo "<tr valign=\"top\">\n";

echo "<td width=\"65%\" class=\"paddedTd\">\n";
echo "<div class=\"optionlistLayer\">\n";
echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n";

$query = "SELECT id_alergia, alergia FROM listaalergias ORDER BY alergia";
$q_alergias = mysql_query($query, $sock);

echo "<input type=\"hidden\" name=\"num_alergias\" value=\"".mysql_num_rows($q_alergias)."\">\n";
$contador = 0;

$sel_alergias = "";
while ($row_alergias = mysql_fetch_object($q_alergias))
{
	$id_alergia = $row_alergias->id_alergia;
	$alergia = $row_alergias->alergia;

	if (isset($arr_alergias) && in_array($id_alergia, $arr_alergias)) $sel_alergias .= $contador.",";

	echo "<input type=\"hidden\" name=\"id_alergia[".$contador."]\" value=\"".$id_alergia."\">\n";
	//echo "<input type=\"hidden\" name=\"txt_alergia[".$contador."]\" value=\"".htmlentities(stripslashes($alergia), ENT_QUOTES)."\">\n";

	echo "<tr valign=\"top\">\n";
	echo "<td width=\"1%\"><input type=\"checkbox\" name=\"alergia[".$contador."]\" class=\"checkBox\"".(isset($arr_alergias) && in_array($id_alergia, $arr_alergias) ? " checked" : "")." onclick=\"selectCheck('sel_alergias', ".$contador.", this.checked); updateInfo1();\"></td>\n";
	echo "<td width=\"99%\"><span id=\"nomalergia_".$contador."\">".stripslashes($alergia)."</span></td>\n";
	echo "</tr>\n";

	$contador ++;
}

echo "<input type=\"hidden\" name=\"sel_alergias\" value=\"".(isset($sel_alergias) ? $sel_alergias : "")."\">\n";

echo "</table>\n";
echo "</div>\n";
echo "</td>\n";

echo "<td width=\"35%\">\n";
echo "<textarea name=\"amp_alergias\" class=\"ampBox\">".(isset($row_pacientes) ? stripslashes($row_pacientes->amp_alergias) : "")."</textarea>\n";
echo "</td>\n";

echo "</tr>\n";
echo "</table>\n";
echo "</td></tr>\n";

echo "</table>\n";
?>
